function switchTab(index) {
		var $o = $("#book_head li[index='"+index+"']");
		var last = $o.parent().find("li.on");
		if(last[0]==$o)return;
		last.removeClass("on");
		$o.addClass("on");
		switchContent(last.attr("index"), $o.attr("index"));
	}
	function switchContent(lastIndex, currIndex) {
		var ROOMS = $("#HOTEL_ROOMS");
		var INFOS = $("#HOTEL_INFO");
		var COMMENT = $("#HOTEL_COMMENT");
		var PHOTOS = $("#HOTEL_PHOTOS");
		var ADDMAP = $("#HOTEL_MAP");
		switch (lastIndex) {
		case "1":
			ROOMS.hide();
			INFOS.hide();
			COMMENT.hide();
			break;
		case "2":
			INFOS.hide();
			break;
		case "3":
			COMMENT.hide();
			break;
		case "4":
			PHOTOS.hide();
			break;
		case "5":
			ADDMAP.hide();
			break;
		default:
			break;
		}
		switch (currIndex) {
		case "1":
			ROOMS.show();
			INFOS.show();
			COMMENT.show();
			break;
		case "2":
			INFOS.show();
			break;
		case "3":
			COMMENT.show();
			break;
		case "4":
			PHOTOS.show();
			break;
		case "5":
			showMap(ADDMAP);
			break;
		default:
			break;
		}
	}
	function showMap(oDiv){
		var iframe = oDiv.find("iframe");
		if(iframe.attr("src") == ""){
			iframe.attr("src","/hotel/hotel_map2.jsp").attr("height","700px").attr("width","700px").css("border","1px solid #ccc");
			if (iframe[0].attachEvent){
			    iframe[0].attachEvent("onload", function(){
			    	iframe[0].contentWindow.showmap(116.307852,40.057031,"百度大厦","北京市海淀区上地十街10号","(010)59928888","百度大厦位于北京市海淀区西二旗地铁站附近，为百度公司综合研发及办公总部。");
			    });
			} else {
			    iframe[0].onload = function(){
			    	iframe[0].contentWindow.showmap(116.307852,40.057031,"百度大厦","北京市海淀区上地十街10号","(010)59928888","百度大厦位于北京市海淀区西二旗地铁站附近，为百度公司综合研发及办公总部。");
			    };
			}
		}
		oDiv.show();
	}
	function switchCommentTab(o) {
		var last = $(o).parent().find("li.con");
		last.removeClass("con");
		$(o).addClass("con");
		//switchContent(last.attr("index"), $(o).attr("index"));
	}
	function hideDiv(e){
		var div = $("div.roomInfo:visible");
		if(div.length==0)return;
		var roomTypeSpan = div.parent().find("span[attr='roomTypeSpan']");
		var left = div.offset().left;
		var top = div.offset().top;
		var height = div.height();
		var width = div.width();
		var sleft = roomTypeSpan.offset().left;
		var stop = roomTypeSpan.offset().top;
		var sheight = roomTypeSpan.height();
		var swidth = roomTypeSpan.width();
		var event = e ? e : (window.event ? window.event : null);
		var x = event.pageX || (event.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft));
		var y = event.pageY || (event.clientY + (document.documentElement.scrollTop || document.body.scrollTop));
		if (!(x>left && x<left+width && y>top && y<top+height)&&!(x>sleft && x<sleft+swidth && y>stop && y<stop+sheight)){
			div.hide();
			}
		}
	window.addEventListener("click",hideDiv,false);
	function showRoomInfo(o){
		var pdiv = $(o).parent().parent();
		var left = pdiv.offset().left;
		var top = pdiv.offset().top;
		var div = pdiv.find("div.roomInfo");
		div.css("left",left);
		//div.css("right",left+width);
		div.css("top",top+53);
		div.show();
	}
//hotel_photos
	function show(o){
		var span = $(o).find("span");
		if(span.css("display")=='none')span.show();
	}
	function hide(o){
		var span = $(o).find("span");
		if(span.css("display")!='none')span.hide();
	}
	var tot_pic_cnt = 0;
	var current_pic_index=1;
	var center_index = 4;
	$(function(){
		init_pic();
	});
	function init_pic(){
		
		$("#pic_list li").click(function(){
			picExchange($(this).attr("pindex"));
		});
		$("#pic_list li:gt(6)").hide();
		tot_pic_cnt = parseInt($("#tot_pic_cnt").text());
	}
	function picExchange(index){
		if(index == current_pic_index)return;
		if(tot_pic_cnt>7){
			if(index>center_index){
				var offset = index - center_index;
				if((parseInt(center_index)+3+offset) > tot_pic_cnt){
					offset = offset - (parseInt(center_index)+3+offset - tot_pic_cnt);
				}
				var ls = parseInt(center_index)-3+offset-1;
				var gs = parseInt(center_index)+3-1;
				$("#pic_list li:lt("+ls+")").hide(100);
				$("#pic_list li:gt("+gs+"):lt("+offset+")").show(100);
			}else{
				var offset = center_index - index;
				if((center_index-3-offset) < 1){
					offset = offset - (1-(center_index-3-offset));
				}
				var ls = parseInt(center_index)+3-offset-1;
				var gs = parseInt(center_index)-3-offset-2;
				$("#pic_list li:gt("+ls+")").hide(100);
				if(gs<0){
					$("#pic_list li:lt("+index+")").show(100);
				}else{
					$("#pic_list li:gt("+gs+"):lt("+offset+")").show(100);
				}
			}
		}
		doChange(index);
	}
	function doChange(index){
		$("li.s_pic_item[pindex='"+current_pic_index+"']").removeClass("on");
		$("li.s_pic_item[pindex='"+index+"']").addClass("on");
		showBigpic(index);//big pic
		current_pic_index = parseInt(index);
		if(current_pic_index<4){
			center_index = 4;
		}else if(current_pic_index>tot_pic_cnt-3){
			center_index = tot_pic_cnt-3;
		}else{
			center_index = current_pic_index;
		}
		return;
	}
	function showBigpic(index){
		$("img#mainPic").attr("src",$("li.s_pic_item[pindex='"+index+"'] img").attr("bigPic"));
		$("#p_index").text(index);
	}
	function next(){
		if(current_pic_index==tot_pic_cnt)return;
		picExchange(current_pic_index+1);
	}
	function prev(){
		if(current_pic_index==1)return;
		picExchange(current_pic_index-1);
	}